package com.handtransaction.dao;

import com.handtransaction.entity.DataBean;
import com.handtransaction.entity.Goods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface DataDao {

    //查询所有数据
    @Select("select * from consoledata ")
    List<DataBean> queryAllData();

    //添加数据
    @Insert("insert into consoledata(userNumber,goodNumber,orderNumber,tipOffNumber,offShelfNumber,transactionAmount,dataTime) " +
            "values(#{userNumber},#{goodNumber},#{orderNumber},#{tipOffNumber},#{offShelfNumber},#{transactionAmount},CURRENT_TIMESTAMP)")
    int insertNewData(DataBean dataBean);

    //商品数量最多前10种类型
    @Select("SELECT gcid,COUNT(gcid) gnumber FROM goods GROUP BY gcid ORDER BY COUNT(gcid) DESC")
    List<Goods> queryMostTenCategory();

    //发生交易的商品类型
    @Select("SELECT gcid,COUNT(gcid) gnumber FROM goods WHERE gtinyint=0 GROUP BY gcid ORDER BY COUNT(gcid) DESC")
    List<Goods> queryOrderCategory();

}
